#include "controlDevice.h"
#include "msg_queue.h"
#include <time.h>
#include <stdlib.h>
#include <pthread.h>
#include <string.h>

/*

struct controlDevice
{
    char name[128]; // 设备名称
    int pin;  // 设别引脚
    int pinStatus; // 引脚状态
    int pinMode; // 引脚模式
    int (*deviceInit)(); // 初始化函数
    int (*open)(); // 打开函数
    int (*close)(); // 关闭函数
    int (*clearConfig)(); // 清除内存

    struct controlDevice *Next;
};


 */


int deepClear(void);
int deepOpen(void);
int deepInit(void);
int deepClose(void);


struct controlDevice deep = {
    .name       = "deep",
    .pin        = 1,
    .pinStatus  = HIGH,
    .pinMode    = OUTPUT,
    .deviceInit = deepInit,
    .clearConfig= deepClear,
    .open       = deepOpen,
    .close      = deepClose
};

int deepOpen(void)
{
    deep.pinStatus = LOW;
    digitalWrite(deep.pin,deep.pinStatus);
}

int deepClose(void)
{
    deep.pinStatus = HIGH;
    digitalWrite(deep.pin,deep.pinStatus);
}

int deepClear(void)
{
    
}

int deepInit(void)
{
    pinMode(deep.pin,deep.pinMode);
    digitalWrite(deep.pin,deep.pinStatus);
    return 1;
}

struct controlDevice* adddeepToDeviceLink(struct controlDevice* phead)
{
    if(phead == NULL)
    {
        return &deep;
    }
    else
    {
        deep.Next = phead;
        phead = &deep;
        return phead;
    }

}

